
<?php


include '../utils/stock.php';
require('../utils/fpdf17/fpdf.php');

class PDF extends FPDF
{
function Header()
{
	global $title;

	// Arial bold 15
	$this->SetFont('Arial','B',15);
	// Calculate width of title and position
	$w = $this->GetStringWidth($title)+6;
	$this->SetX((210-$w)/2);
	// Colors of frame, background and text
	$this->SetDrawColor(0,80,180);
	$this->SetFillColor(230,230,0);
	$this->SetTextColor(220,50,50);
	// Thickness of frame (1 mm)
	$this->SetLineWidth(1);
	// Title
	$this->Cell($w,9,$title,1,1,'C',true);
	// Line break
	$this->Ln(10);
}

function Footer()
{
	// Position at 1.5 cm from bottom
	$this->SetY(-15);
	// Arial italic 8
	$this->SetFont('Arial','I',8);
	// Text color in gray
	$this->SetTextColor(128);
	// Page number
	$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}

function ChapterTitle($num, $label)
{
	// Arial 12
	$this->SetFont('Arial','',12);
	// Background color
	$this->SetFillColor(200,220,255);
	// Title
	$this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
	// Line break
	$this->Ln(4);
}

function ChapterBody($file)
{
	// Read text file
	$txt = file_get_contents($file);
	// Times 12
	$this->SetFont('Times','',12);
	// Output justified text
	$this->MultiCell(0,5,$txt);
	// Line break
	$this->Ln();
	// Mention in italics
	$this->SetFont('','I');
	$this->Cell(0,5,'(end of excerpt)');
}

function PrintChapter($num, $title, $file)
{
	$this->AddPage();
	$this->ChapterTitle($num,$title);
	$this->ChapterBody($file);
}
}


session_start();
$stock = new stock;
$stock->get_stock_quote($_SESSION["symbol"]);

$pdf = new PDF();

$title = $stock->symbol; 
$pdf->SetTitle($title);

$pdf->AddPage();
$pdf->ChapterTitle(1,'SUMMARY');

$pdf->SetFont('Arial','',14);
$pdf->SetX(15);
$pdf->Write(15,'Total debt: ');
$pdf->Write(15,$_SESSION["debt"]);
$pdf->SetX(15);
$pdf->Write(25,'Total equity: ');
$pdf->Write(25,$_SESSION["equity"]);
$pdf->SetX(15);
$pdf->Write(35,'Debt/Equity: ');
$pdf->Write(35,$_SESSION["debtequity"]);
$pdf->SetX(15);
$pdf->Write(45,'Total current assets: ');
$pdf->Write(45,$_SESSION["assets"]);
$pdf->SetX(15);
$pdf->Write(55,'Total current liabilities: ');
$pdf->Write(55,$_SESSION["liabilities"]);
$pdf->SetX(15);
$pdf->Write(65,'Current ratio: ');
$pdf->Write(65,$_SESSION["cr"]);

$pdf->SetX(15);
$pdf->Write(85,'Present book value: ');
$pdf->Write(85,$_SESSION["pbv"]);
$pdf->SetX(15);
$pdf->Write(95,'Future book value: ');
$pdf->Write(95,$_SESSION["fbv"]);
$pdf->SetX(15);
$pdf->Write(105,'Average book value growth: ');
$pdf->Write(105,$_SESSION["bvgrowth"]);

$pdf->SetX(15);
$pdf->Write(125,'Net income: ');
$pdf->Write(125,$_SESSION["netincome"]);
$pdf->SetX(15);
$pdf->Write(135,'Earnings per share: ');
$pdf->Write(135,$_SESSION["eps"]);
$pdf->SetX(15);
$pdf->Write(145,'# shares: ');
$pdf->Write(145,$_SESSION["shares"]);
$pdf->SetX(15);
$pdf->Write(155,'Dividend: ');
$pdf->Write(155,$_SESSION["div"]);
$pdf->SetX(15);
$pdf->Write(165,'Dividend on EPS: ');
$pdf->Write(165,$_SESSION["div"]/$_SESSION["eps"]);
$pdf->SetX(15);
$pdf->Write(175,'Federal note: ');
$pdf->Write(175,$_SESSION["fednote"]);

$pdf->SetX(15);
$pdf->Write(195,'Intrinsic value: ');
$pdf->Write(195,$_SESSION["intrinsicvalue"]);
$pdf->SetX(15);
$pdf->Write(205,'Expected anual return: ');
$pdf->Write(205,$_SESSION["expectedreturn"]);










$pdf->AddPage();
$pdf->ChapterTitle(2,'ANALYSIS');
$pdf->Output($stock->name."_".$stock->date,I);
?>